package com.tc.controller;

import com.tc.dto.Result;
import com.tc.messageDto.Daina;
import com.tc.messageDto.DainaCenter;
import com.tc.service.DainaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RequestMapping("/message")
@RestController
public class DainaController {
    @Autowired
    private DainaService dainaService;

    //发布代拿
    @PostMapping("/addDaina")
    public Result addDaina(@RequestBody Daina information, HttpServletRequest request){
        return dainaService.addDaina(information,request);
    }

    //获取所有代拿订单
    @GetMapping("/getAllDaina/{number}")
    public Result getAllDaina(@PathVariable Integer number){
        return dainaService.getAllDaina(number);
    }

    //获取代拿订单
    @PostMapping("/addMyDaina")
    public Result addMyDaina(@RequestBody DainaCenter dainaCenter, HttpServletRequest request){
        return dainaService.addMyDaina(dainaCenter,request);
    }

    //获取我的所有代拿
    @GetMapping("/selectAllMyDaina")
    public Result selectAllMyDaina(HttpServletRequest request){
        return dainaService.selectAllMyDaina(request);
    }

    //获取所有聊天对象(一)
    @GetMapping("/getMyselfChatFirst")
    public Result getMyselfChatFirst(HttpServletRequest request){
        return dainaService.getMyselfChatFirst(request);
    }

    //获取所有聊天对象(二)
    @GetMapping("/getMyselfChatSecond")
    public Result getMyselfChatSecond(HttpServletRequest request){
        return dainaService.getMyselfChatSecond(request);
    }

    //获取与指定对象的聊天记录
    @GetMapping("/getChatMessage/{id}")
    public Result getChatMessage(@PathVariable Integer id,HttpServletRequest request){
        return dainaService.getChatMessage(id,request);
    }

    //查询对方的个人信息
    @GetMapping("/getUserMessage/{id}")
    public Result getUserMessage(@PathVariable Integer id){
        return  dainaService.getUserMessage(id);
    }
}
